import { Player } from "@minecraft/server";
import { Dimensions } from "@sapi-game/constants";

/**判断是否是裁判 */
export function isReferee(player: Player) {
    return player.hasTag("裁判");
}

export function getFormattedTime(): string {
    const now = new Date();

    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, "0");
    const day = String(now.getDate()).padStart(2, "0");

    const hours = String(now.getHours()).padStart(2, "0");
    const minutes = String(now.getMinutes()).padStart(2, "0");

    return `${year}/${month}/${day} ${hours}:${minutes}`;
}

export function Hub(p: Player) {
    p.teleport(
        { x: 444, y: 5, z: 444 },
        { dimension: Dimensions.Overworld, rotation: { x: 0, y: 90 } }
    );
    p.setSpawnPoint({
        dimension: Dimensions.Overworld,
        x: 444,
        y: 5,
        z: 444,
    });
    p.runCommand("function hub");
}
